package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;
import com.corona.game.util.TextureCache;
import java.util.ArrayList;

/* compiled from: Battle.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/BattleFadeOut.class */
class BattleFadeOut extends Action {
    ArrayList<Sprite> frames;
    Sprite frame;
    int speed;
    public static boolean whiteScreen = false;
    public Action.Layer layer;

    public BattleFadeOut(Game game, Action nextAction) {
        this(game, 1, nextAction);
    }

    public BattleFadeOut(Game game, int speed, Action nextAction) {
        super(new Object[0]);
        this.speed = 1;
        this.layer = Action.Layer.gui_129;
        this.nextAction = nextAction;
        this.speed = speed;
        this.frames = new ArrayList<>();
        Sprite sprite1 = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame6.png")));
        for (int i = 0; i < 14 * this.speed; i++) {
            this.frames.add(sprite1);
        }
        Sprite sprite12 = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame5.png")));
        for (int i2 = 0; i2 < 8 * this.speed; i2++) {
            this.frames.add(sprite12);
        }
        Sprite sprite13 = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame4.png")));
        for (int i3 = 0; i3 < 8 * this.speed; i3++) {
            this.frames.add(sprite13);
        }
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
        if (game.battle.drawAction != null) {
            game.battle.drawAction.cleanup(game);
        }
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.frames.isEmpty()) {
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
            DrawBattle.shouldDrawOwnPokemon = true;
            DrawBattle.shouldDrawOppPokemon = true;
            if (DisplayText.unownText) {
                ArrayList<TrainerTipsTile> signTiles = new ArrayList<>();
                for (Tile tile : game.map.overworldTiles.values()) {
                    if (tile.nameUpper.equals("sign1")) {
                        signTiles.add((TrainerTipsTile) tile);
                    }
                }
                if (signTiles.size() > 0) {
                    signTiles.get(game.map.rand.nextInt(signTiles.size())).isUnown = true;
                }
            }
            DisplayText.unownText = false;
            game.musicController.unownMusic = false;
            game.player.currPokemon.trappedBy = null;
            game.player.currPokemon.trapCounter = 0;
            game.player.currPokemon.disabledIndex = -1;
            game.player.currPokemon.disabledCounter = 0;
            game.player.currPokemon.cantEscapeBy = null;
            game.battle.oppPokemon.canMove = true;
            game.battle.oppPokemon.cantEscapeBy = null;
            return;
        }
        this.frame = this.frames.get(0);
        if (this.frame != null) {
            this.frame.setScale(3.0f);
            this.frame.setPosition(160.0f, 144.0f);
            this.frame.draw(game.uiBatch);
        }
        if (!whiteScreen) {
            this.frames.remove(0);
        }
    }

    /* compiled from: Battle.java */
    /* loaded from: pokewilds.jar:com/pkmngen/game/BattleFadeOut$WhiteScreen.class */
    public static class WhiteScreen extends Action {
        boolean whiteScreen;

        public WhiteScreen(boolean whiteScreen, Action nextAction) {
            super(new Object[0]);
            this.whiteScreen = whiteScreen;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            BattleFadeOut.whiteScreen = this.whiteScreen;
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
        }
    }
}
